package cn.wolfcode.trip.admin.controller;

import cn.wolfcode.trip.base.domain.SystemMessage;
import cn.wolfcode.trip.base.domain.Travel;
import cn.wolfcode.trip.base.query.SystemMessageQuery;
import cn.wolfcode.trip.base.service.ISystemMessageService;
import cn.wolfcode.trip.base.service.ITravelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;


@Controller
@RequestMapping("/systemMessages")
public class SystemMessageController {
    @Autowired
    private ISystemMessageService systemMessageService;
    @Autowired
    private ITravelService travelService;
    /**
     * 查询所有游记列表
     * @return
     */
    @RequestMapping("/save")
    public void save(SystemMessageQuery qo){
        //传入当前用户
        // systemMessageService.query(qo);
        Travel travel = travelService.getById(qo.getTravelId());
        qo.setAuthorId(travel.getAuthor().getId());
        qo.setState(SystemMessage.STATE_NOSEEN);
        systemMessageService.save(qo);
    }


}
